#coding=utf-8
import matplotlib.pyplot as plt 
import math
import numpy as np

PA_VOLUME_NORM = 0X10000
step = 1024
start = step
end = PA_VOLUME_NORM
volume = list(range(start, end, step))
percent = [(v*100.0/PA_VOLUME_NORM) for v in volume]
linear = [(v*1.0/PA_VOLUME_NORM) ** 3.0 for v in volume]
decibel = [20.0 * math.log(lin, 10) for lin in linear]


fig = plt.figure(figsize=(9, 3))

plt.subplot(121)
plt.plot(percent, linear)
plt.xlabel('percent (%)')
plt.ylabel('linear')

plt.subplot(122)
plt.plot(percent, decibel)
plt.xlabel('percent (%)')
plt.ylabel('decibel (dB)')

# plt.subplot(133)
# plt.plot(linear, decibel)
# plt.xlabel('linear')
# plt.ylabel('decibel (dB)')

plt.tight_layout()

plt.subplots_adjust(top=0.88)
plt.show()